{extend name="public/base"/}
{block name="body"}
<style type="text/css">
	.year_id{width:80px;height:30px;border:solid 1px #ddd;}
</style>
<title>编辑大记事</title>
</head>
<body>
<article class="page-container">
	<form class="form form-horizontal section" id="form-admin-add">
		<section>
			<input type="hidden" class="input-text" value="{$data.id}" id="id" name="id">
			<div class="row cl">
				<label class="form-label col-xs-3 col-sm-2">分类：</label>
				<div class="formControls col-xs-8 col-sm-9">
					<select id="year_id" class="year_id" name="year_id">
						{foreach $year as $key=>$value }
						<option value="{$value.id}" {if $value.id==$data.year_id}selected{/if}>{$value.year}</option>
      				{/foreach}
					</select>
				</div>
			</div>
			<div class="row cl">
				<label class="form-label col-xs-3 col-sm-2">年月：</label>
				<div class="formControls col-xs-8 col-sm-9">
					<input type="text" class="input-text" value="{$data.year_month}" placeholder="2019年12月" id="year_month" name="year_month">
				</div>
			</div>
			<div class="row cl">
				<label class="form-label col-xs-3 col-sm-2">大记事：</label>
				<div class="formControls col-xs-8 col-sm-9">
					<textarea rows="6" style="width:100%" name="log">{$data.log}</textarea>
				</div>
			</div>
		</section>
		<div class="row cl">
			<div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-3">
				<input id="submit" class="btn btn-primary radius" type="button" value="&nbsp;&nbsp;提交&nbsp;&nbsp;">
			</div>
		</div>
	</form>
</article>
<script type="text/javascript" src="/public/static/lib/jquery.validation/1.14.0/jquery.validate.js"></script> 
<script type="text/javascript" src="/public/static/lib/jquery.validation/1.14.0/validate-methods.js"></script> 
<script type="text/javascript" src="/public/static/lib/jquery.validation/1.14.0/messages_zh.js"></script> 
<script type="text/javascript">
$("#submit").click(function() {
	layer.load(1, {
	  shade: [0.1,'#fff'] //0.1透明度的白色背景
	});
	var id=$("input[name=id]").val();
	var year_id=$("#year_id").val();
	var year_month=$("input[name=year_month]").val();
	var log=$("textarea[name=log]").val();

	$.ajax({
	    type: 'POST',
	    url: "{:url('biglog_edit')}",
	    data: {id:id,year_id:year_id,year_month:year_month,log:log},
	    success: function(resdata){
	        if(resdata.code==200){
				layer.msg(resdata.msg,{icon:1,time:1000});
				setTimeout("parent.location.reload()",1000);
	        }else{
				layer.msg(resdata.msg,{icon:2,time:3000});
	        }
	    },
	    error: function(){
			layer.msg('数据保存失败',{icon:2,time:3000});
	    }
	})
	
    
})

</script> 

{/block}